package com.caojing.syby.ui.brandsale;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.caojing.syby.R;
import com.caojing.syby.base.BaseFragment;
import com.caojing.syby.ui.brandsale.brandchildfragment.BrandChildFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;

/**
 * A simple {@link Fragment} subclass.
 * 品牌特卖的类
 */
public class BrandsaleFragment extends BaseFragment {



    @Bind(R.id.tab_brand)
    TabLayout tabBrand;
    @Bind(R.id.vp_brand)
    ViewPager vpBrand;
    //存放碎片的集合
    private List<Fragment> mFragmenyList;
    //碎片的编号 最新上线,昨日上新,最后疯狂,精致女装,鞋包配饰,居家生活,美妆个户,美食零食,母婴用品,数码家电,精品男装,文体用品
    private final String NEWEST="99",YESTERDAY="98",LAST="97",DELICACY="1",SHOEBAG="5",LIVINGATHOME="",
                    BEAUTYMAKEUP="9",CATE="",INFANTMOM="", NUMERICALCODE="8",BOUTIQUE="2",LITERARYFORM="10";
    private String [] bclass=new String[]{NEWEST,YESTERDAY,LAST,DELICACY,SHOEBAG,LIVINGATHOME,
            BEAUTYMAKEUP,CATE,INFANTMOM, NUMERICALCODE,BOUTIQUE,LITERARYFORM};
    private String[] tabName;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_brandsale;
    }

    @Override
    protected void initView(View view) {
        tabName = getResources().getStringArray(R.array.brandTabName);
        mFragmenyList=new ArrayList<>();
        for (int i=0;i<tabName.length;i++){
            BrandChildFragment brandChildFragment= BrandChildFragment.newInstance(bclass[i]);
            mFragmenyList.add(brandChildFragment);
        }


//        BrandChildFragment brandChildFragment1= new BrandChildFragment();
//        Bundle bundle = new Bundle();
//        bundle.putInt("index",NEWEST);
//        brandChildFragment1.setArguments(bundle);
//
//        BrandChildFragment brandChildFragment2= new BrandChildFragment();
//        bundle = new Bundle();
//        bundle.putInt("index",YESTERDAY);
//        brandChildFragment1.setArguments(bundle);
//
//        BrandChildFragment brandChildFragment3= new BrandChildFragment();
//        bundle = new Bundle();
//        bundle.putInt("index",LAST);
//        brandChildFragment1.setArguments(bundle);
//
//        BrandChildFragment brandChildFragment4= new BrandChildFragment();
//        bundle = new Bundle();
//        bundle.putInt("index",DELICACY);
//        brandChildFragment1.setArguments(bundle);
//
//        BrandChildFragment brandChildFragment5= new BrandChildFragment();
//        bundle = new Bundle();
//        bundle.putInt("index",SHOEBAG);
//        brandChildFragment1.setArguments(bundle);
//        BrandChildFragment brandChildFragment6= new BrandChildFragment();
//        bundle = new Bundle();
//        bundle.putInt("index",LIVINGATHOME);
//        brandChildFragment1.setArguments(bundle);
//
//        BrandChildFragment brandChildFragment7= new BrandChildFragment();
//        bundle = new Bundle();
//        bundle.putInt("index",BEAUTYMAKEUP);
//        brandChildFragment1.setArguments(bundle);
//
//        BrandChildFragment brandChildFragment8= new BrandChildFragment();
//        bundle = new Bundle();
//        bundle.putInt("index",CATE);
//        brandChildFragment1.setArguments(bundle);
//
//        BrandChildFragment brandChildFragment9= new BrandChildFragment();
//        bundle = new Bundle();
//        bundle.putInt("index",INFANTMOM);
//        brandChildFragment1.setArguments(bundle);
//
//        BrandChildFragment brandChildFragment10= new BrandChildFragment();
//        bundle = new Bundle();
//        bundle.putInt("index",NUMERICALCODE);
//        brandChildFragment1.setArguments(bundle);
//
//        BrandChildFragment brandChildFragment11= new BrandChildFragment();
//        bundle = new Bundle();
//        bundle.putInt("index",BOUTIQUE);
//        brandChildFragment1.setArguments(bundle);
//
//        BrandChildFragment brandChildFragment12= new BrandChildFragment();
//        bundle = new Bundle();
//        bundle.putInt("index",LITERARYFORM);
//        brandChildFragment1.setArguments(bundle);
//
//        mFragmenyList.add(brandChildFragment1);
//        mFragmenyList.add(brandChildFragment2);
//        mFragmenyList.add(brandChildFragment3);
//        mFragmenyList.add(brandChildFragment4);
//        mFragmenyList.add(brandChildFragment5);
//        mFragmenyList.add(brandChildFragment6);
//        mFragmenyList.add(brandChildFragment7);
//        mFragmenyList.add(brandChildFragment8);
//        mFragmenyList.add(brandChildFragment9);
//        mFragmenyList.add(brandChildFragment10);
//        mFragmenyList.add(brandChildFragment11);
//        mFragmenyList.add(brandChildFragment12);
        tabBrand.setTabMode(TabLayout.MODE_SCROLLABLE);

    }

    @Override
    protected void initData() {

        //获取tabLayout的文字

        BrandFragmentVpAdapter adapter = new BrandFragmentVpAdapter(getChildFragmentManager(), tabName,mFragmenyList);
        vpBrand.setAdapter(adapter);
        tabBrand.setupWithViewPager(vpBrand);

    }

}
